home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / Makefile < prev    next >
Makefile  |  1994-04-04  |  9KB  |  241 lines

  1. # Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3.  
  4. # The GNU C Library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Library General Public License as
  6. # published by the Free Software Foundation; either version 2 of the
  7. # License, or (at your option) any later version.
  8.  
  9. # The GNU C Library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. # Library General Public License for more details.
  13.  
  14. # You should have received a copy of the GNU Library General Public
  15. # License along with the GNU C Library; see the file COPYING.LIB.  If
  16. # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. # Cambridge, MA 02139, USA.
  18.  
  19. #
  20. #    Master Makefile for the GNU C library
  21. #
  22. ifneq (,)
  23. This makefile requires GNU Make.
  24. endif
  25.  
  26.  
  27. # This is the default target; it makes everything except the tests.
  28. .PHONY: all
  29. all: lib others
  30.  
  31. configure: configure.in
  32.     autoconf $(ACFLAGS)
  33.  
  34. %/configure: %/configure.in
  35.     autoconf $(ACFLAGS) $< > $@.new
  36.     mv $@.new $@
  37.  
  38. include Makeconfig
  39.  
  40. include $(objpfx)sysd-dirs
  41. define \n
  42.  
  43.  
  44. endef
  45. sysdep-subdirs := $(subst $(\n), ,$(sysdep-subdirs))
  46.  
  47. # These are the subdirectories containing the library source.
  48. +ansi_dirs    := assert ctype locale math setjmp \
  49.            signal stdio stdlib malloc string time
  50. +posix_dirs    := dirent grp pwd posix io termios
  51. +other_dirs    := resource socket misc gnulib $(wildcard crypt) manual
  52. subdirs        := $(strip $(+ansi_dirs) $(+posix_dirs) $(+other_dirs) \
  53.                $(sysdep-subdirs))
  54. export subdirs := $(subdirs)    # Benign, useless in GNU make before 3.63.
  55.  
  56. # The mach and hurd subdirectories have many generated header files which
  57. # the much of rest of the library depends on, so it is best to build them
  58. # first (and mach before hurd, at that).  The before-compile additions in
  59. # sysdeps/{mach,hurd}/Makefile should make it reliably work for these files
  60. # not to exist when making in other directories, but it will be slower that
  61. # way with more somewhat expensive `make' invocations.
  62. subdirs    := $(filter mach,$(subdirs)) $(filter hurd,$(subdirs)) \
  63.        $(filter-out mach hurd,$(subdirs))
  64.  
  65. # All initialization source files.
  66. +subdir_inits    := $(wildcard $(foreach dir,$(subdirs),$(dir)/init-$(dir).c))
  67. # All subdirectories containing initialization source files.
  68. +init_subdirs    := $(patsubst %/,%,$(dir $(+subdir_inits)))
  69.  
  70.  
  71. # These are the targets that are made by making them in each subdirectory.
  72. +subdir_targets    := subdir_lib objects objs others subdir_mostlyclean    \
  73.            subdir_clean subdir_distclean subdir_realclean    \
  74.            tests subdir_lint.out                \
  75.            subdir_echo-headers subdir_echo-distinfo        \
  76.            subdir_install $(addprefix install-,            \
  77.                           no-libc.a bin lib        \
  78.                           data headers others)
  79.  
  80. headers := features.h errno.h sys/errno.h errnos.h limits.h $(stddef.h)
  81.  
  82. echo-headers: subdir_echo-headers
  83.  
  84. ifdef +gnu-stabs
  85. # We're using the GNU linker, so we use the set-element init function.
  86. +init := set-init
  87. else
  88. # We're not using the GNU linker, so we use the munch init function.
  89. +init := munch-init
  90.  
  91. $(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
  92.     awk -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
  93.     mv $@-t $@
  94. generated := $(generated) munch-init.c
  95. endif
  96.  
  97. aux    := sysdep $(+init) version start
  98.  
  99.  
  100. # What to install.
  101. # SCO 3.2v4 uses crt1.o.  Some other system uses Mcrt1.o.
  102. # They are created below (containing no data or code).
  103. install-lib = crt0.o crt1.o Mcrt1.o    # libc.a is done by Makerules.
  104. install-others = $(includedir)/stubs.h
  105.  
  106.  
  107. include Makerules
  108.  
  109. # Install from subdirectories too.
  110. install: subdir_install
  111.  
  112. # `crt0' is the traditional name for the startup code,
  113. # so that's what we install start.o as.
  114. $(objpfx)crt0.o: $(objpfx)start.o
  115.     -rm -f $@
  116.     ln $< $@
  117.  
  118. $(objpfx)Mcrt1.o $(objpfx)crt1.o:
  119.     cp /dev/null $(@:.o=.c)
  120.     $(COMPILE.c) $(@:.o=.c) $(OUTPUT_OPTION)
  121.     rm -f $(@:.o=.c)
  122.  
  123. lib-noranlib $(libc.a)(__.SYMDEF): subdir_lib
  124.  
  125.  
  126. $(objpfx)sysd-dirs: $(+sysdir_pfx)config.make
  127.     (echo define sysdep-subdirs;                          \
  128.      for dir in $(sysdirs); do                          \
  129.        if [ -r $(sysdep_dir)/$$dir/Subdirs ]; then                  \
  130.          cat $(sysdep_dir)/$$dir/Subdirs;                      \
  131.        else true;                                  \
  132.        fi;                                      \
  133.      done;                                      \
  134.      echo endef) > $@-tmp
  135.      mv $@-tmp $@
  136.  
  137. # Makerules creates a file `stub-$(subdir)' for each subdirectory, which
  138. # contains `#define __stub_FUNCTION' for each function which is a stub.
  139. # Here we paste all of these together into <stubs.h>.
  140.  
  141. subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)stub-$(dir))
  142.  
  143. # Since stubs.h is never needed when building the library, we simplify the
  144. # hairy installation process by producing it in place only as the last part
  145. # of the top-level `make install'.  It depends on subdir_install, which
  146. # iterates over all the subdirs; subdir_install in each subdir depends on
  147. # the subdir's stubs file.  Having more direct dependencies would result in
  148. # extra iterations over the list for subdirs and many recursive makes.
  149. $(includedir)/stubs.h: subdir_install
  150.     @rm -f $(objpfx)stubs.h
  151.     (echo '/* This file is automatically generated.';\
  152.      echo '   It defines a symbol `__stub_FUNCTION'\'' for each function';\
  153.      echo '   in the C library which is a stub, meaning it will fail';\
  154.      echo '   every time called, usually setting errno to ENOSYS.  */';\
  155.      sort $(subdir-stubs)) > $(objpfx)stubs.h
  156.     $(INSTALL_DATA) $(objpfx)stubs.h $@
  157.     rm -f $(objpfx)stubs.h
  158.  
  159. # This makes the Info or DVI file of the documentation from the Texinfo source.
  160. .PHONY: info dvi
  161. info dvi:
  162.     $(MAKE) -C manual $@
  163.  
  164. # This makes all the subdirectory targets.
  165.  
  166. # For each target, make it depend on DIR/target for each subdirectory DIR.
  167. $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
  168.  
  169. # Compute a list of all those targets.
  170. all-subdirs-targets := $(foreach dir,$(subdirs),\
  171.                  $(addprefix $(dir)/,$(+subdir_targets)))
  172.  
  173. # The action for each of those is to cd into the directory and make the
  174. # target there.
  175. $(all-subdirs-targets):
  176.     $(MAKE) -C $(@D) $(@F)
  177.  
  178. .PHONY: $(+subdir_targets) $(all-subdirs-targets)
  179.  
  180. # Targets to clean things up to various degrees.
  181.  
  182. .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean
  183.  
  184. # Subroutines of all cleaning targets.
  185. parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
  186.     -rm -f $(libc.a) $(addprefix $(objpfx),$(install-lib))
  187. parent-clean: parent-mostlyclean common-clean
  188.     -rm -f $(addprefix $(common-objpfx),$(common-generated))
  189.     -rm -f $(addprefix $(+sysdir_pfx),sysd-Makefile sysd-dirs sysdirs)
  190.  
  191. clean: parent-clean
  192. # This is done this way rather than having `subdir_clean' be a
  193. # dependency of this target so that libc.a will be removed before the
  194. # subdirectories are dealt with and so they won't try to remove object
  195. # files from it when it's going to be removed anyway.
  196.     @$(MAKE) subdir_clean no_deps=t
  197. mostlyclean: parent-mostlyclean
  198.     @$(MAKE) subdir_mostlyclean no_deps=t
  199.  
  200. # The realclean target is just like distclean for the parent, but we want
  201. # the subdirs to know the difference in case they care.
  202. realclean distclean: parent-clean
  203. # This is done this way rather than having `subdir_distclean' be a
  204. # dependency of this target so that libc.a will be removed before the
  205. # subdirectories are dealt with and so they won't try to remove object
  206. # files from it when it's going to be removed anyway.
  207.     @$(MAKE) distclean-1 no_deps=t distclean-1=$@
  208.  
  209. # Subroutine of distclean and realclean.
  210. distclean-1: subdir_$(distclean-1)
  211.     -rm -f $(config-generated)
  212.     -rm -f $(addprefix $(objpfx),config.status config.make)
  213. ifdef objdir
  214.     -rm -f $(objpfx)Makefile
  215. endif
  216.  
  217. .PHONY: echo_subdirs
  218. echo_subdirs:;@echo '$(subdirs)'
  219.  
  220. .PHONY: echo-distinfo parent_echo-distinfo
  221. echo-distinfo: parent_echo-distinfo subdir_echo-distinfo
  222. parent_echo-distinfo:
  223.     @echo $(addprefix +header+,$(headers)) \
  224.           $(addprefix +nodist+,$(generated))
  225.  
  226. # Make the distribution tarfile.
  227.  
  228. distribute  := README INSTALL NOTES COPYING.LIB COPYING ChangeLog NEWS    \
  229.            Makefile Makeconfig Makerules Rules Make-dist MakeTAGS    \
  230.            ansidecl.h mkinstalldirs move-if-change install.sh    \
  231.            configure configure.in aclocal.m4 config.sub config.guess\
  232.            munch-tmpl.c munch.awk gnu-stabs.h sysdep.h set-hooks.h
  233.  
  234. distribute := $(strip $(distribute))
  235. generated := $(generated) stubs.h
  236.  
  237. README: README.template version.c ; # Make-dist should update README.
  238.  
  239. INSTALL: manual/maint.texi
  240.     makeinfo --no-validate --no-warn --no-headers $< -o $@
  241.